package com.endpoint.author.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.endpoint.author.to.BookContentTo;
import com.endpoint.author.to.BookIndexTo;
import com.endpoint.author.to.BookTo;
import com.endpoint.common.utils.ResultBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @Project: endpoint
 * @Name: BookFeign
 * @Author: Jack_Li
 * @Date: 2024/7/7 15:16
 */
@FeignClient("endpoint-book")
public interface BookFeignService {

    @GetMapping("/book/getBookByAuthorId")
    public ResultBean<Page<BookTo>> getBookByAuthorId(@RequestParam("authorId") Long authorId,
                                                      @RequestParam("pageNum") int pageNum,
                                                      @RequestParam("pageSize") int pageSize);

    @GetMapping("/book/bookIndex/list")
    public ResultBean<Page<BookIndexTo>> getBookIndexByBookId(@RequestParam("bookId") Long bookId,
                                                      @RequestParam("pageNum") int pageNum,
                                                      @RequestParam("pageSize") int pageSize);

    @PostMapping("/book/saveBook")
    public ResultBean<Void> saveBook(@RequestBody BookTo book);

    @GetMapping("/book/checkBookName")
    public ResultBean<Long> checkBookName(@RequestParam("bookName")String bookName);

    @GetMapping("/book/getById")
    public ResultBean<BookTo>getById(@RequestParam("bookId")Long bookId);

    @GetMapping("/book/bookIndex/getlastChapterByBookId")
    public ResultBean<BookIndexTo> getlastChapterByBookId (@RequestParam("bookId")Long bookId);

    @PostMapping("/book/bookIndex/saveChapter")
    public ResultBean<BookIndexTo>saveChapter(@RequestBody BookIndexTo bookIndex);

    @PostMapping("/book/bookContent/saveContent")
    public ResultBean<Void> saveContent(@RequestBody BookContentTo bookContent);

    @PutMapping("/book/updateBook")
    public ResultBean<Void> updateBook(@RequestBody BookTo book);

}
